unit CfopDM;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  ZDataset, ZSqlUpdate, MainDM,QueryConditions, db;

type

  { TCfopData }

  TCfopData = class(TMainDataModule)
    CfopDatasource: TDatasource;
    CfopZQuery: TZQuery;
    CfopZQuerycode: TStringField;
    CfopZQuerydesc_cfop: TStringField;
    CfopZUpdate: TZUpdateSQL;

    procedure DataModuleCreate(Sender: TObject);
    /// Abre o DataSet
    procedure OpenDataSet(); override;
    /// Fecha o DataSet
    procedure CloseDataSet(); override;
    /// Realiza busca
    /// @param(Condicoes são as condições para a busca)
    /// @param(Tabela é a tabela no banco de dados)
    procedure Search(Condicoes: TQueryConditions; Tabela: string); override;
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  CfopData: TCfopData;

implementation

uses ConnectionDM;

{ TCfopData }

procedure TCfopData.DataModuleCreate(Sender: TObject);
begin
  MainDataSet := CfopZQuery;
 // CfopZQuery.Open;
end;

procedure TCfopData.OpenDataSet;
begin
  // ConnectionData.EmptyQuery(CfopZQuery, 'cfop');
     ConnectionData.EmptyQuery(CfopZQuery, 'cfop');
end;

procedure TCfopData.CloseDataSet;
begin
  // CfopZQuery.Close();
     CfopZQuery.Close();
end;


procedure TCfopData.Search(Condicoes: TQueryConditions; Tabela: string);
begin
   ConnectionData.OpenQueryConditions(CfopZQuery, Tabela, Condicoes);
end;

initialization
  {$I cfopdm.lrs}

end.

